/*
 * @Description: 登陆相关函数
 * @Author: YWJ 
 * @Date: 2022-04-24 15:21:19 
 * @Last Modified by: YWJ
 * @Last Modified time: 2022-05-14 10:46:41
 */

import request from '@/request'

export function login(user){
  return request({
    method:'get',
    url:'/user/login',
    params:user
  })
}

export function register(user) {
	return request({
		  method: 'post',
		  url: '/user/regist',
          data: user,
          headers:{
              "ContentType":"application/json"
          }
		})
}

export function getUserInfo() {
	return request({
		  method: 'get',
		  url: '/users/currentUser',
		})
}

export function logout() {
    return request({
      url: '/logout',
      method: 'get'
    })
  }

  export function changeNickname(data) {
    return request({
        method: 'post',
        url: '/user-center/change-nickname',
        params: {
          account:localStorage.getItem("account"),
          nickname:data
        },
        headers: {
          ContentType: "application/json",
          token: localStorage.getItem("token"),
        }
      })
  }

  export function changePassword(oldPwd,newPwd) {
    return request({
        method: 'post',
        url: '/user-center/change-pwd',
        params: {
          account:localStorage.getItem("account"),
          oldPwd:oldPwd,
          newPwd:newPwd
        },
        headers: {
          ContentType: "application/json",
          token: localStorage.getItem("token"),
        }
      })
  }

  export function changeAvatar(params) {
    return request({
        method: 'post',
        url: '/user-center/change-avator',
        params: {
          account:localStorage.getItem("account"),
          pic:params
        },
        headers: {
          ContentType: "application/json",
          token: localStorage.getItem("token"),
        }
      })
  }